home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / knewstuff / engine.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  5.1 KB  |  189 lines

  1. /*
  2.     This file is part of KOrganizer.
  3.     Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef KNEWSTUFF_ENGINE_H
  21. #define KNEWSTUFF_ENGINE_H
  22.  
  23. #include <qmap.h>
  24. #include <qobject.h>
  25. #include <qstring.h>
  26.  
  27. #include "entry.h"
  28. #include "provider.h"
  29.  
  30. namespace KIO { class Job; }
  31.  
  32. class KNewStuff;
  33.  
  34. namespace KNS {
  35.  
  36. class DownloadDialog;
  37. class UploadDialog;
  38. class ProviderDialog;
  39.  
  40. /**
  41.  * @short Central class combining all possible KNewStuff operations.
  42.  *
  43.  * In most cases, Engine objects are built and used internally.
  44.  * Using this class explicitely does however give fine-grained control about the
  45.  * upload and download operations.
  46.  *
  47.  * @author Cornelius Schumacher (schumacher@kde.org)
  48.  * \par Maintainer:
  49.  * Josef Spillner (spillner@kde.org)
  50.  */
  51. class KDE_EXPORT Engine : public QObject
  52. {
  53.     Q_OBJECT
  54.     struct Private;
  55.   public:
  56.     /**
  57.       Constructor.
  58.  
  59.       @param newStuff a KNewStuff object
  60.       @param type the Hotstuff data type such as "korganizer/calendar"
  61.       @param parentWidget the parent window
  62.     */
  63.     Engine( KNewStuff *newStuff, const QString &type, QWidget *parentWidget = 0 );
  64.     /**
  65.       Constructor.
  66.  
  67.       @param newStuff a KNewStuff object
  68.       @param type the Hotstuff data type such as "korganizer/calendar"
  69.       @param providerList the URL of the provider list
  70.       @param parentWidget the parent window
  71.     */
  72.     Engine( KNewStuff *newStuff, const QString &type, const QString &providerList, QWidget *parentWidget = 0 );
  73.  
  74.     /**
  75.       Destructor.
  76.     */
  77.     virtual ~Engine();
  78.  
  79.     /**
  80.       Returns the previously set data type.
  81.  
  82.       @return the Hotstuff data type
  83.     */
  84.     QString type() const { return mType; }
  85.  
  86.     /**
  87.       Returns the previously set parent widget.
  88.  
  89.       @return parent widget
  90.     */
  91.     QWidget *parentWidget() const { return mParentWidget; }
  92.  
  93.     /**
  94.       Initiates the download process, retrieving provider lists and invoking
  95.       the download dialog.
  96.     */
  97.     void download();
  98.  
  99.     /**
  100.       Initiates the upload process, invoking the provider selection dialog
  101.       and the file upload dialog.
  102.  
  103.       @param fileName name of the payload data file
  104.       @param previewName name of the preview image file
  105.     */
  106.     void upload( const QString &fileName = QString::null, const QString &previewName = QString::null );
  107.  
  108.     /**
  109.       Downloads the specified data file.
  110.  
  111.       @param entry the Hotstuff data object to be downloaded
  112.     */
  113.     void download( Entry *entry );
  114.  
  115.     /**
  116.       Asynchronous lookup of provider information such as upload and
  117.       download locations, icon etc.
  118.  
  119.       @param provider the Hotstuff provider to request information from
  120.     */
  121.     void requestMetaInformation( Provider *provider );
  122.  
  123.     /**
  124.       Uploads the specified data file to the provider-dependent location.
  125.  
  126.       @param entry the Hotstuff data object to be uploaded
  127.     */
  128.     void upload( Entry *entry );
  129.     
  130.     /**
  131.     Ignores the return value of the install method. Used internally to
  132.     avoid showing of the success/failure dialog when installation is done
  133.     in another place, like in @ref KNewStuffSecure
  134.      */
  135.     void ignoreInstallResult(bool ignore);   
  136.  
  137.   signals:
  138.     /** Emitted when the upload has finished.
  139.       @param result indicates the success/failure of the upload
  140.     */
  141.     void uploadFinished( bool result );
  142.   protected slots:
  143.     void getMetaInformation( Provider::List *providers );
  144.     void selectUploadProvider( Provider::List *providers );
  145.  
  146.     void slotNewStuffJobData( KIO::Job *job, const QByteArray &data );
  147.     void slotNewStuffJobResult( KIO::Job *job );
  148.  
  149.     void slotDownloadJobResult( KIO::Job *job );
  150.  
  151.     void slotUploadPayloadJobResult( KIO::Job *job );
  152.     void slotUploadPreviewJobResult (KIO::Job *job );
  153.     void slotUploadMetaJobResult( KIO::Job *job );
  154.  
  155.   protected:
  156.     bool createMetaFile( Entry * );
  157.     
  158.   private:
  159.     QWidget *mParentWidget;
  160.  
  161.     ProviderLoader *mProviderLoader;
  162.  
  163.     QMap<KIO::Job *,QString> mNewStuffJobData;
  164.     QMap<KIO::Job *,Provider *> mProviderJobs;
  165.  
  166.     QPtrList<Entry> mNewStuffList;
  167.  
  168.     DownloadDialog *mDownloadDialog;
  169.     UploadDialog *mUploadDialog;
  170.     ProviderDialog *mProviderDialog;
  171.  
  172.     QString mDownloadDestination;
  173.  
  174.     Provider *mUploadProvider;
  175.  
  176.     QString mUploadMetaFile;
  177.     QString mUploadFile;
  178.     QString mPreviewFile;
  179.     QString mProviderList;
  180.  
  181.     Private* d;
  182.  
  183.     QString mType;
  184. };
  185.  
  186. }
  187.  
  188. #endif
  189.